
var modifyUser ;
var deleteUser;
var viewUser;

$(function () {
    modifyUser = $(".modifyUser");
    deleteUser = $(".deleteUser");
    viewUser = $(".viewUser");

    modifyUser.bind("click",function () {
        var userId = $(this).attr("userid");
        window.location.href = path+"/user/modify?userId="+userId;
    });

    deleteUser.bind("click",function () {

        $(".zhezhao").fadeIn(500);
        $("#removeUse").fadeIn(1000);
        var userId =  $(this).attr("userid");
        $("#yes").bind("click",function () {
            window.location.href = path+"/user/delete?userId="+userId;
            // $(".zhezhao").hide();
            // $("#removeUse").hide();
        });
        $("#no").bind("click",function () {
            $(".zhezhao").fadeOut(1000);
            $("#removeUse").fadeOut(500);
        });
    });

    viewUser.bind("click",function () {
        var userId = $(this).attr("userid");
        // window.location.href = path+"/user/modify?userId="+userId;
        // window.location.href = path+"/user/view/"+userId;

        $.ajax({
            type:'GET',
            url:path+'/user/view/'+userId,
            data:{},
            dataType:'json',
            success:function (result) {
                // console.log(result);
                if(result != null ){
                    $("#userCode").html(result.userCode);
                    $("#userName").html(result.userName);
                    if(result.gender == 1){
                        $("#gender").html("女");
                    }else {
                        $("#gender").html("男");
                    }
                    $("#birthday").html(result.birthday);
                    $("#phone").html(result.phone);
                    $("#address").html(result.address);
                    $("#userRole").html(result.userRoleName);
                    $("#idPicPath").attr("src",path+result.idPicPath);
                }
            },
            error:function () {
                alert("查询用户信息异常！");
            }
        });
    });
});